package com.ternnetwork.core.configuration.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.ternnetwork.commons.utils.JsonUtils;
import com.ternnetwork.persistence.entity.VersionEntity;




/**
 * 系列实体类
 * @author xuwenfeng
 *
 */
@Entity
//name="AVO_SEQ" 为该实体类对应的数据库表名，按实际来改动
@Table(name="AVO_SEQ")
//value={"handler","hibernateLazyInitializer" 代表handler与hibernateLazyInitializer不会进行json字符串转换
@JsonIgnoreProperties(value={"handler","hibernateLazyInitializer"})
public class Seq extends VersionEntity{
	@Id@Column(name="ID",nullable=false)
	@GeneratedValue(strategy = GenerationType.TABLE,generator="id_gen")
	//pkColumnValue="SEQ_ID"代表使用主键管理中主键名称为SEQ_ID的这条数据的下一个值作为此主键的值
	//每个实体类的pkColumnValue对应的值都应该不一样 
    @TableGenerator(name = "id_gen",pkColumnValue="SEQ_ID",table="AVO_ID_GENERATOR", pkColumnName="GEN_NAME",valueColumnName="GEN_VALUE",allocationSize=1)
	private long id;
	
	//名称
	//name="name"表字段名为name,nullable=false表示不能为空,unique=true表示不可重复
	@Column(name="name",nullable=false,unique=true)
	private String name;
	
	//长度
	@Column(name="length",nullable=false)
	private Integer length;
	
	//前缀
	@Column(name="PREFIX",nullable=false)
	private String prefix;
	
	//下一个值
	@Column(name="NEXT_VALUE",nullable=false)
	private Long nextValue;
	
	//增长幅度
	@Column(name="ALLOCATION_SZIE",nullable=false)
	private Long allocationSize;
	
	
	
	

	public void setId(long id) {
		this.id = id;
	}
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public Integer getLength() {
		return length;
	}
	
	public void setLength(Integer length) {
		this.length = length;
	}
	public String getPrefix() {
		return prefix;
	}
	public void setPrefix(String prefix) {
		this.prefix = prefix;
	}
	public Long getNextValue() {
		return nextValue;
	}
	public void setNextValue(Long nextValue) {
		this.nextValue = nextValue;
	}
	public Long getAllocationSize() {
		return allocationSize;
	}
	public void setAllocationSize(Long allocationSize) {
		this.allocationSize = allocationSize;
	}


	@Override
	public String toString() {
		return JsonUtils.objectToJson(this);
	}

	@Override
	public Long getId() {
		
		return id;
	}
	

}
